<template>
    <div>
      <Toast :tenantName="tenantName"></Toast>
      <NavBar :tenantName="tenantName" :tenantId="tenantId"></NavBar>
      <div style="display: flex">
        <Asider ></Asider>
        <div style="width: 1400px;">
          <Content :tenantId="tenantId"></Content>
        </div>
      </div>
    </div>
  </template>
  <script>
  import NavBar from "@/components/main/NavBar.vue";
  import Toast from "@/components/main/Toast.vue";
  import Asider from "@/components/main/Asider.vue";
  import Content from "@/components/main/Content.vue";
  import {decode} from 'js-base64'
  export default {
    name: "IoT",
    data(){
      return {
        tenantId: '',
        tenantName:''
      }
    },
    components: {
      NavBar,
      Toast,
      Asider,
      Content,
    },
    mounted(){
      let token = sessionStorage.getItem("token");
			let payload = token.substring(token.indexOf(".")+1, token.lastIndexOf("."));
      let tenant =JSON.parse(decode(payload));
      this. tenantId =tenant.jti;
      this.tenantName =tenant.sub;
      sessionStorage.setItem("tenantId",tenant.jti);
      // console.log(tenantId);
			// let tenant = JSON.parse(j1);
			// console.log(tenant);
    }
  };
  </script>
  
  <style scoped>
  #app {
    font-family: Avenir, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: center;
    color: #2c3e50;
  }
  
  nav {
    padding: 30px;
  }
  
  nav a {
    font-weight: bold;
    color: #2c3e50;
  }
  
  nav a.router-link-exact-active {
    color: #42b983;
  }
  </style>
  